
	$(function(){
	
		//加载搜索引擎数据
		//initAutoNoArea();
	    //默认初始客栈索引
		//initHotelSug();
		$("#default_v_radio").attr("checked",true);

	});
	
	var advcnt=1;
	function switchadv(){
	 var ele=document.getElementById("indexadvlink");
	 if(ele==null){
	 	return;
	 }
	 advcnt=parseInt(advcnt)+1;
	 if(parseInt(advcnt)%2==1){

	 	$("#indexadvlink").attr("href","http://car.wodingche.com");
	 	$("#indexadvlink").attr("title","国内租车取车前24小时随时退款");
	 	$("#indexadvimg").attr("src","http://images.wodingche.com/images/frontend/qmy/indexrefund.gif");
	 }else if(parseInt(advcnt)%2==0){
	 	$("#indexadvlink").attr("href","http://intercar.wodingche.com");
	 	$("#indexadvlink").attr("title","国际租车");
	 	$("#indexadvimg").attr("src","http://images.wodingche.com/images/frontend/qmy/advertisement.gif");
	 	
	 }else{
	 }
	}
	
	
	
	//客栈地区弹出层事件
	function cLocationClickPop(){	
		if($('#cLocation').val()=='城市名'){
			$('#cLocation').val('');
		}
		initHotCityHide();		
		searchCommon('cLocation','1');
	}
	
	//本地还车地弹出层事件
	function noLocationClickPop(){		
		if($('#no-l-name').val()=='城市名'){
			$('#no-l-name').val('');
		}
		$("#loc-seat").hide();
		initHotCityHide();	
		searchCommon('no-l-name','2');
	}
	
	//异地还车出发地弹出层事件
	function noLocationStartPop(){
		if($('#no-l-carry-name').val()=='城市名'){
			$('#no-l-carry-name').val('');
		}
		initHotCityHide();	
		searchCommon('no-l-carry-name','2');
	}
	
	//异地还车结束地弹出层事件
	function noLocationEndPop(){
		if($('#no-l-return-name').val()=='城市名'){
			$('#no-l-return-name').val('');
		}
		
		initHotCityHide();	

		if($("#no-l-carry-id").val() != null){
		    var url = "/frontend/vehicle/vehicle!loadAutoCityForIndex.action?queryVo.flag=150&queryVo.startLocationId="+$("#no-l-carry-id").val();
		    $("#r-text20").load(encodeURI(url));
			searchCommon('no-l-return-name','20');		
		}
	}
	



	
	//日租地区弹出层事件
	function dateLocationPop(){
		if($('#with-l-name').val()=='城市名'){
			$('#with-l-name').val('');
		}
		$("#with-seat").hide();
		initHotCityHide();	
		searchCommon('with-l-name','2');
	}
	
	//代驾包车下面四个选项框的选择操作
	function viewOptionTab(tab){
		
	    $('#tuna_address').hide();
	    $(".spopup").each(function(e){
	    	$(this).hide();
	    });
		initHotCityHide();
	    for(var i=0;i<4;i++){
	       if(tab == i){

	          $("#radioAirCheck"+i).addClass("font_tx");
	       }else{
	       	  $("#radioAirCheck"+i).removeClass("font_tx");

	       }
	       if(i==0){
	       		$("#with-seat").show();
	       }else  if(i==1){
	       		$("#away-air-seat").show();
	       }else  if(i==2){
	       		$("#air-away-seat").show();
	       }else  if(i==3){
	       		$("#a-b-seat").show();
	       }
	    }
	    
		if(tab == 0){
			$("#away_air_span").hide();
			$("#line_span").hide();
			$("#with_s_span").hide();
			$("#at_air_span").show();
			//initAuto();
			
		}else if(tab == 1){
			$("#line_span").hide();
			$("#at_air_span").hide();
			$("#with_s_span").hide();
			$("#away_air_span").show();
			//initAutoAwayToAir();
			
		}else if(tab == 2){
			$("#at_air_span").hide();
			$("#away_air_span").hide();
			$("#with_s_span").hide();
			$("#line_span").show();
			//initAutoRount();
			
		}else if(tab == 3){
			$("#at_air_span").hide();
			$("#away_air_span").hide();
			$("#line_span").hide();
			$("#with_s_span").show();
			
		}
	}
	
	//推荐客栈切换操作
	function displayContent(n){
	    var locationId=$("#link_poilocationId_"+n).val();
	     var url="/ajax/load/loadIndexHotelTagInfo.action?locationId="+locationId+"&s="+new Date().getTime();
		if($("#tagList_"+n).html().length<20){
			$.get(url,function(response){
			    $("#tagList_"+n).html(response);
			    showHotelTagInfo(n);
			});
		}else{
			showHotelTagInfo(n);
		}
	}
	
	function showHotelTagInfo(n){
		for(var m=0;m<5;m++){
	        if(m ==n){
	            if($("#hotDesc_"+m)[0]){
	                $("#hotDesc_"+m).removeClass();
	                $("#hotDesc_"+m).addClass("qmy-cities-on");
	            }
	            if($("#tagList_"+m)[0]){
	                $("#tagList_"+m).show();
	            }
	            if($("#linkDisPoiLocation_"+m)[0]){
		            var link = document.getElementById("link_poilocationId_"+m);
	                if(link!=null && link!=undefined){
	                    var url = "/deals/hotel/"+ link.value +"/1.html";
	                    $("#linkDisPoiLocation_"+m).attr("href",url);
	                }
		        }
	        }else{
	            if($("#hotDesc_"+m)[0]){
	                $("#hotDesc_"+m).removeClass();
	                $("#hotDesc_"+m).addClass("qmy-cities-off");
	            }
	            if($("#tagList_"+m)[0]){
	                $("#tagList_"+m).hide();
	            }
	        }
	    }
	}
	//目的地搜索跳转
    function locationScenic(){
        var locationId = $('#hLocationId').val();
        var location  = $('#hotLocation').val();
	    if(locationId==null || locationId=='' || location==''){
	        showHotDestion();
	    }
	    window.location.href = "/popdestination/"+locationId+".html";
	    window.location.target = "_blank";
    }
     	
	
    //显示热门目的地弹出层
    function showHotDestion(){
    	//初始化人们目的地索引
        initHotLocationSug();
        
     	$('#hot-input-text7').css("position","absolute");
        $input = $('#hotLocation');
		$suggest = $('#hot-input-text7');
		$suggest.css("position","absolute");
		var offset = $input.offset();
		$suggest.css("margin","0 0 0 0");
		$suggest.css({"left":offset.left,"top":offset.top+$input.height()+5});
		$suggest.show();
		return false;
    }
	
	//初始化地区和客栈的数据索引
	
	

	
	//初始化热门地区的数据

	
    function changelocation(){
	    $('#hot-input-text1').hide();
	    $('#hot-input-text2').hide();
	}
	
	function changelocation1(){
	    $('#hot-input-text1').hide();
	    $('#hot-input-text2').hide();
	}

	function setLocationId(){

	}
	
	function changeRecmAdv(obj){
		$("#advlist").each(function(i){
			$(this).find(".qmy-best-big").hide();
			$(this).find(".qmy-best-small").show();
		});
		$(obj).hide();
		$(obj).parent().find(".qmy-best-big").show();
	}


     //团购显示切换
     function changeTabTuanGou(tab){
	     var str = "";
	     var json ;
	     n = 0;
	     if(tab == 0){
	         if(groupDealsjson1 != null && groupDealsjson1.length > 0){
	             if(groupDealsjson1.length > 2){
	                  n = 2;
	             }else{
	                  n = groupDealsjson1.length;
	             }
	             str = convertJsonToStr(groupDealsjson1,n,1);
	         }
	         if(groupDealsjson2 != null && groupDealsjson2.length > 0){
	             if(groupDealsjson2.length > 2){
	                  n = 2;
	             }else{
	                  n = groupDealsjson2.length;
	             }
	             str += convertJsonToStr(groupDealsjson2,n,2);
	         }
	     }else{
		     if(tab == 1){
	             json = groupDealsjson1;
		     }else if(tab == 2){
		         json = groupDealsjson2;
		     }
		     if(json != null && json.length > 0){
		     	 if(json.length > 4){
	                  n = 4;
	             }else{
	                  n = json.length;
	             }
	             str = convertJsonToStr(json,n,0);
             }
         }
	     $("#tuan-tab-content").html(str);
	     for(var j=0;j<3;j++){
	         if(j == tab){
	             $("#tuan-change-"+j).removeClass();
	             $("#tuan-change-"+j).addClass("qmy-tuan-on yahei");
	         }else{
	        	 $("#tuan-change-"+j).removeClass();
	             $("#tuan-change-"+j).addClass("qmy-tuan-off yahei");
	         }
	     }

	 }
	 
	 //将json转换成字符窜
	 function convertJsonToStr(json,n,type){
	     var str = "";
         for(var i=0;i<n;i++){
             var j = 0;
             if(type == 2){
                 j = i+2;
             }else{
                 j = i;
             }
             if(j == 0){
                 str += "<span class='qmy-tuan-onclick' id='view-tuan-"+j+"' onmouseover=this.className='qmy-tuan-onclick'  onmouseout=this.className='qmy-tuan-in'>";
             }else{
                 str += "<span class='qmy-tuan-in' id='view-tuan-"+j+"' onmouseover=$('#view-tuan-0').removeClass();$('#view-tuan-0').addClass('qmy-tuan-in');this.className='qmy-tuan-onclick';  onmouseout=this.className='qmy-tuan-in'>";
             }
             str += "<span class='qmy-tuan-icon'></span>";
             str += "<span class='qmy-tuan-price yahei'><a href='http://tuan.wodingche.com/deals/"+json[i].id+".html' title='"+json[i].titleDesc+"' target='_blank'>"+ json[i].price +"</a></span>";
             str += "<div style='clear:both;'></div>";
             str += "<span class='qmy-tuan-title'><a href='http://tuan.wodingche.com/deals/"+json[i].id+".html' title='"+json[i].titleDesc+"' target='_blank'>"+ json[i].title +"</a></span>";
             str += "<span class='qmy-tuan-msg'><a href='http://tuan.wodingche.com/deals/"+json[i].id+".html' title='"+json[i].describe+"' target='_blank'><strong>["+json[i].type+"]</strong> "+json[i].description+"</a></span>";
             str += "<span class='qmy-tuan-pic'><a href='http://tuan.wodingche.com/deals/"+json[i].id+".html' title='"+json[i].titleDesc+"' target='_blank'><img src='"+json[i].coverUrl+"' width='120' height='84' border='0'/></a></span>";
             str += "<span class='qmy-tuan-total'><a href='http://tuan.wodingche.com/deals/"+json[i].id+".html' target='_blank'>折扣 <strong class='text-yellow text-14px'>"+json[i].discount+"</strong> 折<br/>原价 <span class='line-through text-14px'>￥"+json[i].salePrice+"</span></a></span>";
             str += "</span>";
         }
         return str;
	 }
	 
	 //切换团购类型显示
	 function changeTabGroupBuy(tab){
	 	 for(var j=0;j<3;j++){
	         if(j == tab){
	             $("#tuan-tab-content"+j).show();
	             $("#tuan-change-"+j).removeClass();
	             $("#tuan-change-"+j).addClass("qmy-tuan-on yahei");
	         }else{
	        	 $("#tuan-tab-content"+j).hide();
	        	 $("#tuan-change-"+j).removeClass();
	             $("#tuan-change-"+j).addClass("qmy-tuan-off yahei");
	         }
	     }
	 }
	 
	 //热门客栈搜索
	 function searchHotel(){
	    if($.trim($('#startDate').val())=='入住时间'){
	        $('#startDate').val('');
	    }
	    if($.trim($('#endDate').val())=='离店时间'){
	        $('#endDate').val('');
	    }
	    if($.trim($('#cHotelName').val())=='' && ($.trim($('#cLocation').val())=='' || $.trim($('#cLocation').val())=='城市名')){
	        searchCommon('cLocation','1');
	    }else{
	       if ($.browser.safari) {
  				var a= $("#queryHotelForm").attr("action")+($("#queryHotelForm").attr("action").indexOf('?') == -1 ? '?' : '&');
  				$("#queryHotelForm").attr("action",a+'t=' + new Date().getTime());
			}
		    $('#queryHotelForm').submit();
	    }
	}
	
	//代驾自驾的大TAB的切换操作
	function changeTabVehicle(tab){
	     $('#tuna_address').hide();
	    $(".spopup").each(function(e){
	    	$(this).hide();
	    });
	   
	    if(tab == 1){
	        $('#spanTabNoDriver').show();
	        $('#spanTabWithDriver').hide();
	        $("#viewTabNoDriver").removeClass();
	        $("#viewTabWithDriver").removeClass();
	        $("#viewTabNoDriver").addClass("qmy-view-tab-on-m-in");
	        $("#viewTabNoDriver1").removeClass();
	        $("#viewTabNoDriver1").addClass("qmy-view-tab-on-l");
	        $("#viewTabNoDriver2").removeClass();
	        $("#viewTabNoDriver2").addClass("qmy-view-tab-on-m");
	        $("#viewTabNoDriver3").removeClass();
	        $("#viewTabNoDriver3").addClass("qmy-view-tab-on-r");
	        $("#viewTabWithDriver1").removeClass();
	        $("#viewTabWithDriver1").addClass("qmy-view-tab-off-l");
	        $("#viewTabWithDriver2").removeClass();
	        $("#viewTabWithDriver2").addClass("qmy-view-tab-off-m");
	        $("#viewTabWithDriver3").removeClass();
	        $("#viewTabWithDriver3").addClass("qmy-view-tab-off-r");
	        isDifferentPlace(1);
	    }else{
	        $('#spanTabNoDriver').hide();
	        $('#spanTabWithDriver').show();
	        $("#viewTabWithDriver").removeClass();
	        $("#viewTabNoDriver").removeClass();
	        $("#viewTabWithDriver").addClass("qmy-view-tab-on-m-in");
	        $("#viewTabWithDriver1").removeClass();
	        $("#viewTabWithDriver1").addClass("qmy-view-tab-on-l");
	        $("#viewTabWithDriver2").removeClass();
	        $("#viewTabWithDriver2").addClass("qmy-view-tab-on-m");
	        $("#viewTabWithDriver3").removeClass();
	        $("#viewTabWithDriver3").addClass("qmy-view-tab-on-r");
	        $("#viewTabNoDriver1").removeClass();
	        $("#viewTabNoDriver1").addClass("qmy-view-tab-off-l");
	        $("#viewTabNoDriver2").removeClass();
	        $("#viewTabNoDriver2").addClass("qmy-view-tab-off-m");
	        $("#viewTabNoDriver3").removeClass();
	        $("#viewTabNoDriver3").addClass("qmy-view-tab-off-r");
	        $("#default_v_radio").attr("checked",true);
	        viewOptionTab(3);
	    }
	    initHotCityHide();
	}
	
	//是否异地还车的切换
	function isDifferentPlace(type){
	    if(type == 1){
	        $('#differentPlaceYes').hide();
	        $('#differentPlaceVehicle').hide();
	        $('#differentPlaceNo').show();
	        $('#localPlaceVehicle').show();
	        $('#loc-seat').show();
	    }else{
	        $('#differentPlaceYes').show();
	        $('#differentPlaceVehicle').show();
	        $('#differentPlaceNo').hide();
	        $('#localPlaceVehicle').hide();
			$('#dif-seat').show();
	    }
	}
	
	//本地还车按钮提交操作
	function localVehicleSearch(type){
	
		if(type == 1){
			//如果是本地还车
			var name = $("#no-l-name").val();
			var startTime=$.trim($("#carryTime").val());
			var endTime=$.trim($("#returnTime").val());
			if(startTime == ''){
				$("#carryTime").val('');
			}
			if(endTime == ''){
				$("#returnTime").val('');
			}

			//var myArray = new Array()
			//var checkseat = $("#loc-seat").val();
			//myArray = checkseat.split("_");
			//$("#loc-b-seat").val(myArray[0]);
			//$("#loc-e-seat").val(myArray[1]);
	
			if(name.indexOf("租车城市") > -1 || name == null || name == ""){
				inputClick('noDriver');
				$("#no-l-name").focus();
				$("#no-l-id").val("");
			}else{
				//用车时间
				if(startTime=='请选择取车时间'||endTime=='请选择还车时间'||startTime==''||endTime==''){
					if(startTime=='请选择取车时间'||startTime==''){
						$("#carryTime").focus();
						$("#carryTime").addClass("text_error");
					}else if(endTime=='请选择还车时间'||endTime==''){
						$("#returnTime").focus();
						$("#returnTime").addClass("text_error");
					}
					return;
				}else{
					$("#carryTime").removeClass("text_error");
					$("#returnTime").removeClass("text_error");
					if(isValidDate(startTime)==false){
						$("#carryTime").focus();
						$("#carryTime").addClass("text_error");
						return;
					}
					if(isValidDate(endTime)==false){
						$("#returnTime").focus();
						$("#returnTime").addClass("text_error");
						return;
					}
					if(endTime<=startTime){
						$("#returnTime").focus();
						$("#returnTime").addClass("text_error");
						return;
					}else{
						$("#returnTime").removeClass("text_error");
					}
					
					if(DateDiff(endTime,startTime)>=parseInt($("#rentalDays").val())){
						
						$("#nd_sub_tip").children(".popup-tip-t").html('您的租期超过30天，请拨打订车网客服电话400－118－0101以获得更优惠的价格！');
						$("#nd_sub_tip").show();
						return;
					}else{
						$("#nd_sub_tip").hide();
					}
					if(endTime>$("#maxDate").val()){
						$("#nd_sub_tip").children(".popup-tip-t").html('您选取的租车日期已超出未来90天的范围，请拨打订车网客服电话400－118－0101以获得更精确的报价！');
						$("#nd_sub_tip").show();
						return;
					}else{
						$("#nd_sub_tip").hide();
					}
				}
				
				
				$("#no-l-carry-id").val("");
				$("#no-l-return-id").val("");
				$("#no-l-carry-name").val("");
				$("#no-l-return-name").val("");
				if ($.browser.safari) {
  					var a= $("#noSearchForm").attr("action")+($("#noSearchForm").attr("action").indexOf('?') == -1 ? '?' : '&');
  					$("#noSearchForm").attr("action",a+'t=' + new Date().getTime());
				}
				$("#noSearchForm").submit();	
	
			}	
		}else if(type == 2){
			//如果是异地还车
			var carryName = $("#no-l-carry-name").val();
			var giveName = $("#no-l-return-name").val();
			if(carryName == "租车城市"){
				$("#no-l-carry-name").val("");
				carryName = $("#no-l-carry-name").val();
			}
			if(giveName == "还车城市"){
				$("#no-l-return-name").val("");
				giveName = $("#no-l-return-name").val();
			}
			var startTime=$.trim($("#carryTime1").val());
			var endTime=$.trim($("#returnTime1").val());
			
			if(startTime == '请选择取车时间'){
				$("#carryTime1").val('');
			}
			if(endTime== '请选择还车时间'){
				$("#returnTime1").val('');
			}
			
			
			//var myArray = new Array()
			//var checkseat = $("#dif-seat").val();
			//myArray = checkseat.split("_");
			//$("#dif-b-seat").val(myArray[0]);
			//$("#dif-e-seat").val(myArray[1]);
			
			if(carryName == "" && giveName == ""){
				inputClick('difNoDriver');
				$("#no-l-carry-name").focus();			
			}else{
				
				//用车时间
				if(startTime==''||endTime==''){
					alert("请选择取车时间及还车时间!");
					return;
				}else{
					if(isValidDate(startTime)==false){
						alert("提车时间格式不正确,请重新输入!");
						return;
					}
					if(isValidDate(endTime)==false){
						alert("还车时间格式不正确,请重新输入!");
						return;
					}
					if(endTime<=startTime){
						alert("还车时间必须晚于提车时间!");
						return;
					}
					if(DateDiff(endTime,startTime)>=parseInt($("#rentalDays").val())){
						alert("您的租期超过30天，请拨打订车网客服电话400－118－0101以获得更优惠的价格！");
						return;
					}
					if(endTime>$("#maxDate").val()){
						alert("您选取的租车日期已超出未来90天的范围，请拨打订车网客服电话400－118－0101以获得更精确的报价！");
						return;
					}
				}
							
				if(carryName == ""){
					$("#no-l-carry-id").val("");	
				}
				if(giveName == ""){
					$("#no-l-return-id").val("");
				}
				$("#no-l-id").val("");
				$("#no-l-name").val("");
				
				if ($.browser.safari) {
  					var a= $("#noSearchForm1").attr("action")+($("#noSearchForm1").attr("action").indexOf('?') == -1 ? '?' : '&');
  					$("#noSearchForm1").attr("action",a+'t=' + new Date().getTime());
				}
				$("#noSearchForm1").submit();					
			}
		}
	}
	
	
	
	//本地还车按钮提交操作
	function localVehicleSearchNoDate(type){
		
		var seats=$("#no-seats").val();
		if(seats!=''){
			var seatsinfo=seats.split("_");
			
			$("#loc-b-seat").val(seatsinfo[0]);
			$("#loc-e-seat").val(seatsinfo[1]);
		}
		
		if(type == 1){
			var name = $("#no-l-name").val();
			
			if(name.indexOf("租车城市") > -1 || name == null || name == ""){
				inputClick('noDriver');
				$("#no-l-name").focus();
				$("#no-l-id").val("");
			}else{

				$("#no-l-carry-id").val("");
				$("#no-l-return-id").val("");
				$("#no-l-carry-name").val("");
				$("#no-l-return-name").val("");
				if ($.browser.safari) {
  					var a= $("#noSearchForm").attr("action")+($("#noSearchForm").attr("action").indexOf('?') == -1 ? '?' : '&');
  					$("#noSearchForm").attr("action",a+'t=' + new Date().getTime());
				}
				$("#noSearchForm").submit();	
	
			}	
		}
	}
	

	
	//接机加载飞机场
	function loadAirPort(){
	     var locationId = $("#air-away1-b-id").val();
	    var locationName = $("#air-away1-b-name").val();
		var url = "/frontend/vehicle/vehicle!loadAirPortSpanForIndex.action?queryVo.locationName=" + locationName + "&queryVo.locationId=" + locationId + "&queryVo.type=0&s=" + new Date().getTime();
		$.get(encodeURI(url),function(data){
			$("#air-away-port").html($.trim(data));
		});
	}
	
	function loadAirPort2(){
	    var locationId = $("#away-air1-e-id").val();
	    var locationName = $("#away-air1-e-name").val();
		var url = "/frontend/vehicle/vehicle!loadAirPortSpanForIndex.action?queryVo.locationName=" + locationName + "&queryVo.locationId=" + locationId + "&queryVo.type=1&s=" + new Date().getTime();
		$.get(encodeURI(url),function(data){
			$("#away-air-port").html($.trim(data));
		});
	}


	
	//接机送机form提交
	function withCarSubmit(){
		
		var form = $("form[name='rentCarForm']:visible");
		var type = form.find("input[name='queryVo.type']").val();
		if ($.browser.safari) {
  			var a= $(form).attr("action")+($(form).attr("action").indexOf('?') == -1 ? '?' : '&');
  			$(form).attr("action",a+'t=' + new Date().getTime());
		}
		
		if(type == 0){
			airawayBeforeSubmit(form);
		}else if(type==1){
			awayairBeforeSubmit(form);
		}else if(type==2){
			rountBeforeSubmit(form);
		}else if(type==3){
			
			dayRentBeforeSubmit(form);
		}
	}
	
	function airawayBeforeSubmit(form){
		
		var b_name = $("#air-away1-b-name").val();
		var e_name = $("#air-away-e-name").val();	
	    if(b_name.indexOf("接机城市") > -1 || b_name == null || b_name == ""){
	    	pickLocationStartPop();
	    	inputClick('airportCity_from');
			$("#air-away1-b-name").focus();	
			
			return;
	    }else{

		    var locationId = null;

			if((b_name.indexOf("接机城市") > -1 || b_name == null || b_name == "")){
				$("#air_away_tip").text("请选择城市");
				pickLocationStartPop();
	    		inputClick('airportCity_from');
				return;
			}
			
			if(e_name.indexOf("送达地") > -1 || e_name == ""){
				//$("#air-away-e-name").val("");
				//$("#air-away-e-id").val("");

				terminalLoc('fromAirportTerminal');
				return;
			}else{
				$("#air-away-e-name").addClass("text_error");
			}
			if(b_name.indexOf("接机城市") > -1 || b_name == ""){
				$("#air-away1-b-name").val("");
				$("#air-away1-b-id").val("");
			}
			if($("#air-away-time").val()=="接人时间"){
				$("#air-away-time").val("");
			}
			var checkval =  $("input[name='airPortRadio']:visible:checked").val();
			if(checkval != "" && checkval != null && checkval != "undefined"){
				var arr = checkval.split("_");
				if(arr.length > 1){
					$("#air-away-b-id").val(arr[0]);
					$("#air-away-b-name").val(arr[1]);	
				}
			}
			//var myArray = new Array()
			//var checkseat = $("#air-away-seat").val();
			//myArray = checkseat.split("_");
			//$("#air-away-b-seat").val(myArray[0]);
			//$("#air-away-e-seat").val(myArray[1]);
			
			form.submit();
		}
	}
	
	function awayairBeforeSubmit(form){
		var loctionId = null;
	    var b_name = $("#away-air-b-name").val();
		var e_name = $("#away-air1-e-name").val();
		if(e_name.indexOf("送机城市") > -1 || e_name == null || e_name == ""){
			pickLocationStartPop();
			inputClick('airportCity_to');
			$("#away-air1-e-name").focus();	
		}else{
			
			if(b_name.indexOf("接人地") > -1 || b_name == ""){
				//$("#away-air-b-name").val("");
				//$("#away-air-b-id").val("");
				terminalLoc('toAirportTerminal');
				return;
			}else{
				$("#away-air-b-name").removeClass("text_error");
			}
			if(e_name.indexOf("送机城市") > -1 || e_name == ""){
				$("#air-away-e-name").val("");
				$("#away-air1-e-id").val("");
			}
			if($("#away-air-time").val()=="接人时间"){
				$("#away-air-time").val("");
			}
			var checkval =  $("input[name='airPortRadio']:visible:checked").val();
			if(checkval != "" && checkval != null && checkval != "undefined"){
				var arr = checkval.split("_");
				if(arr.length > 1){
					$("#away-air-e-id").val(arr[0]);
					$("#away-air-e-name").val(arr[1]);
				}
			}
			//var myArray = new Array()
			//var checkseat = $("#away-air-seat").val();
			//myArray = checkseat.split("_");
			//$("#away-air-b-seat").val(myArray[0]);
			//$("#away-air-e-seat").val(myArray[1]);
			
			form.submit();		
		}
	}
	function rountBeforeSubmit(form){
		var t_name = $("#rount-t-name").val();
		var f_name = $("#rount-f-name").val();
		if((t_name =="目的地" || t_name=="" || t_name == null) && (f_name=="出发地" || f_name=="" || f_name == null)){
			inputClick('a2b');
			$("#rount-f-name").focus();		
		}else{

			if(f_name.indexOf("出发地") > -1 || f_name == ""){
				//$("#rount-f-name").val("");
				//$("#rount-f-id").val("");
				inputClick('a2b');
				return;
			}else{
				$("#rount-f-name").removeClass("text_error");
			}
			
			if(t_name.indexOf("目的地") > -1 || t_name == ""){
				//$("#rount-t-name").val("");
				//$("#rount-t-id").val("");
				terminalLoc('a2bTerminal');
				return;
			}else{
				$("#rount-t-name").removeClass("text_error");
			}
			
			if($("#rountTime").val()=="接人时间"){
				$("#rountTime").val("");
			}
			//var myArray = new Array()
			//var checkseat = $("#a-b-seat").val();
			//myArray = checkseat.split("_");
			//$("#a2b-b-seat").val(myArray[0]);
			//$("#a2b-e-seat").val(myArray[1]);
			form.submit();		
		}
	}
	
	function dayRentBeforeSubmit(form){
		
		var name = $("#with-l-name").val();
		if(name == '包车城市' || name == null || name== "" ){
			
			inputClick('withDriver');
			$("#with-l-name").focus();	
		}else{
			
			$("#with-l-name").removeClass("text_error");
			
			var startTime=$.trim($("#withTime").val());
			if( startTime== '请选择开始时间'||startTime==''){
				$("#withTime").val('请选择开始时间');
				$("#withTime").addClass("text_error");
				$("#withTime").focus();
				return;
			}else{
				$("#withTime").removeClass("text_error");
			}
			
			var withDays=$.trim($("#withDays").val());
			if( withDays== '包车天数'||withDays==''){
				$("#withDays").val('包车天数');
				$("#withDays").addClass("text_error");
				return;
			}else{
				$("#withDays").removeClass("text_error");
			}
			//用车时间
			if(startTime==''){
				alert("请选择开始时间!");
				return;
			}else{
				
				if(isValidDate(startTime)==false){
					$("#withTime").addClass("text_error");
					$("#withTime").focus();
					return;
				}
				
				if(parseInt(withDays)>=parseInt($("#rentalDays").val())){
						$("#wd_sub_tip").children(".popup-tip-t").html('您的租期超过30天，请拨打订车网客服电话400－118－0101以获得更优惠的价格！');
						$("#wd_sub_tip").show();
				}else{
					$("#wd_sub_tip").hide();
				}
				
				if(GetDateStr2(startTime,parseInt(withDays))>$("#maxDate").val()){
					$("#wd_sub_tip").children(".popup-tip-t").html('您选取的租车日期已超出未来90天的范围，请拨打订车网客服电话400－118－0101以获得更精确的报价！');
					$("#wd_sub_tip").show();
					return;
				}else{
					$("#wd_sub_tip").hide();
				}
				
			}
			//var myArray = new Array()
			//var checkseat = $("#with-seat").val();
			//myArray = checkseat.split("_");
			//$("#w-b-seat").val(myArray[0]);
			//$("#w-e-seat").val(myArray[1]);
			
			form.submit();	
		}
	}
	function timeout(){
	
	}
	//隐藏座次下拉框
	function hideSelectSeats(){
		$("#select-seats-1").hide();
	    $("#select-seats-2").hide();
	    $("#select-seats-3").hide();
	    $("#select-seats-4").hide();
	    $("#select-seats-5").hide();
	    $("#select-seats-6").hide();
	}
	
	//设定座位次
	function setSeats(name,value,value1){
		$("#"+name).val(value);
		$("#"+name+"-input").val(value1);
		hideSelectSeats();
	}
	
	function moreRount(startId, startName, type){
	    $("#car_href_form").attr("action","/frontend/vehicle/vehicle!queryRountMore.action");
		$("#car_href_form").find("input").remove();
		$("#car_href_form").append("<input type='hidden' name='queryVo.startLocationId' value='"+startId+"'/>");
		$("#car_href_form").append("<input type='hidden' name='queryVo.locationName' value='"+startName+"'/>");
		$("#car_href_form").append("<input type='hidden' name='queryVo.type' value='"+type+"'/>");
		if ($.browser.safari) {
  				var a= $("#car_href_form").attr("action")+($("#car_href_form").attr("action").indexOf('?') == -1 ? '?' : '&');
  				$("#car_href_form").attr("action",a+'t=' + new Date().getTime());
		}
		$("#car_href_form").submit();
	}
	
	function moreAirToAway(startId, startName){
	    $("#car_href_form").attr("action","/frontend/vehicle/vehicle!queryRountMore.action");
		$("#car_href_form").find("input").remove();
		$("#car_href_form").append("<input type='hidden' name='queryVo.endLocationId' value='"+startId+"'/>");
		$("#car_href_form").append("<input type='hidden' name='queryVo.locationName2' value='"+startName+"'/>");
		$("#car_href_form").append("<input type='hidden' name='queryVo.type' value='0'/>");
		if ($.browser.safari) {
  				var a= $("#car_href_form").attr("action")+($("#car_href_form").attr("action").indexOf('?') == -1 ? '?' : '&');
  				$("#car_href_form").attr("action",a+'t=' + new Date().getTime());
		}
		$("#car_href_form").submit();
	}
	
	function moreAwayToAir(startId, startName){
	    $("#car_href_form").attr("action","/frontend/vehicle/vehicle!queryRountMore.action");
		$("#car_href_form").find("input").remove();
		$("#car_href_form").append("<input type='hidden' name='queryVo.startLocationId' value='"+startId+"'/>");
		$("#car_href_form").append("<input type='hidden' name='queryVo.locationName' value='"+startName+"'/>");
		$("#car_href_form").append("<input type='hidden' name='queryVo.type' value='1'/>");
		if ($.browser.safari) {
  				var a= $("#car_href_form").attr("action")+($("#car_href_form").attr("action").indexOf('?') == -1 ? '?' : '&');
  				$("#car_href_form").attr("action",a+'t=' + new Date().getTime());
		}
		$("#car_href_form").submit();
	}
	
	function moreWithDriver(locId,locName,carBrand){
		$("#car_href_form").attr("action","/frontend/vehicle/vehicle!queryWithDriverMore.action");
		$("#car_href_form").find("input").remove();
		$("#car_href_form").append("<input type='hidden' name='queryVo.locationId' value='"+locId+"'/>");
		$("#car_href_form").append("<input type='hidden' name='queryVo.locationName' value='"+locName+"'/>");
		$("#car_href_form").append("<input type='hidden' name='queryVo.carModel' value='"+carBrand+"'/>");
		if ($.browser.safari) {
  				var a= $("#car_href_form").attr("action")+($("#car_href_form").attr("action").indexOf('?') == -1 ? '?' : '&');
  				$("#car_href_form").attr("action",a+'t=' + new Date().getTime());
		}
		$("#car_href_form").submit();
	}
	
	function moreNoDriver(locId,locName,carBrand){
		$("#car_href_form").attr("action","/frontend/vehicle/vehicle!queryNoDriverMore.action");
		$("#car_href_form").find("input").remove();
		$("#car_href_form").append("<input type='hidden' name='queryVo.locationId' value='"+locId+"'/>");
		$("#car_href_form").append("<input type='hidden' name='queryVo.locationName' value='"+locName+"'/>");
		$("#car_href_form").append("<input type='hidden' name='queryVo.carModel' value='"+carBrand+"'/>");
		if ($.browser.safari) {
  				var a= $("#car_href_form").attr("action")+($("#car_href_form").attr("action").indexOf('?') == -1 ? '?' : '&');
  				$("#car_href_form").attr("action",a+'t=' + new Date().getTime());
		}
		$("#car_href_form").submit();
	}
	
	function carOnLine(startId,startName,endId,endName){
		$("#car_href_form").attr("action","/frontend/vehicle/vehicle!queryRount.action");
		$("#car_href_form").find("input").remove();
		$("#car_href_form").append("<input type='hidden' name='queryVo.startLocationId' value='"+startId+"'/>");
		$("#car_href_form").append("<input type='hidden' name='queryVo.locationName' value='"+startName+"'/>");
		$("#car_href_form").append("<input type='hidden' name='queryVo.endLocationId' value='"+endId+"'/>");
		$("#car_href_form").append("<input type='hidden' name='queryVo.locationName2' value='"+endName+"'/>");
		$("#car_href_form").append("<input type='hidden' name='queryVo.type' value='2'/>");
		$("#car_href_form").append("<input type='hidden' name='queryVo.flag' value='true'/>");
		if ($.browser.safari) {
  				var a= $("#car_href_form").attr("action")+($("#car_href_form").attr("action").indexOf('?') == -1 ? '?' : '&');
  				$("#car_href_form").attr("action",a+'t=' + new Date().getTime());
		}
		$("#car_href_form").submit();
	}
	
	 function showBj(){
	 				
	 				var offset = $("#tophead").offset();

					var top=offset.top;
					var left=offset.left;
					var winWidth=$(window).width();
					var leftWidth=(winWidth-1000)/2;
					
					if ($.browser.msie && ($.browser.version == "6.0") && !$.support.style) {
						
						if(leftWidth<173){
							left=left-420;
						}else{
							left=left-420;
						}
					}else{
						if(leftWidth<173){
							left=left-420;
						}else{
							left=left-420;
						}
					}
					
					$('#announce').css({'position': 'absolute','top':top + 'px', 'left':left + 'px', 'z-index':100});
	 }
	 function selfDrive(opt){
	 	if(opt=='sd'){
	 		$('#sd_1').show();
	 		$('#sd_2').hide();
	 		$("#sd1_lab").addClass("font_tx");
	 		$("#sd2_lab").removeClass("font_tx");
	 	}else{
	 		
	 		$('#sd_2').show();
	 		$('#sd_1').hide();
	 		$("#sd2_lab").addClass("font_tx");
	 		$("#sd1_lab").removeClass("font_tx");
	 	}
	 	
	 }
	 
	 
	 //安飞士展示框 
	 function avis_show(bool){
	 	if(bool){
	 		$(".afs .afs_head:first").hide();
	 		$(".afs .afs_tc:first").show();
	 	}else{
	 		$(".afs .afs_head:first").show();
	 		$(".afs .afs_tc:first").hide();
	 	}
	 }
	 
	 
	 